<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="search.css">
</head>

<body>
    <div class="box">
        <div class="title"><span>&lt;</span>搜索</div>
        <div id="app">
            <div class="inputBox">
                <input type="text" placeholder="搜索商家、商品名称" v-model="inputText">
                <span @click="add">搜索</span>
            </div>

            <div class="history">
                <section class="top">
                    <span>历史搜索</span>
                    <span class="btn">删除</span>
                </section>
                <div class="item" v-for="(item,index) in tasklist" :key="index">
                    <div>{{item.name}}</div>
                </div>
            </div>
            <div class="find">
                <span>搜索发现</span>
                <div>麻辣烫</div>
                <div>米线</div>
                <div>披萨</div>
                <div>蛋糕</div>
                <div>汉堡</div>
                <div>腊八粥</div>
                <div>烤肉拌饭</div>
                <div>炸鸡</div>
                <div>味多美(遇阳路店)</div>
            </div>
        </div>
    </div>
</body>

</html>
<script src="./vue-2.5.21.js"></script>
<script>
    var v = new Vue({
        el: '#app',
        data: {
            inputText: '',
            tasklist: [
            {id:1, name:'天天鲜挪威三文鱼（立水桥店）'} 
            ]
        },
        methods: {
            //添加历史记录
            add() {
                if (this.inputText) {
                    var obj = {id: this.tasklist.length + 1,name:this.inputText};
                    //清空输入框
                    this.inputText='';
                }
                // console.log( this.inputText)
            }
        }
    })
</script>